[Python] name 'OptionGroup' is not defined

Posted by Cawas on Stack Overflow See other posts from Stack Overflow or by Cawas
Published on 2010-05-13T20:27:56Z Indexed on 2010/05/13 20:54 UTC
Read the original article Hit count: 347

Filed under:
|
|

Ok, so I made this rookie mistake below, but in my defense I was led to it thanks to how the help about this subject is on python docs, which states how to use optparse. It is actually an error under the gigantic tutorial section. In contrast and to my offense, I may be one of the very few stupid people who can't read very well and pay close attention on what I do.

But since this took me so long to discover, I wanted to "document" it here:

Python 2.6.1 (r261:67515, Feb 11 2010, 00:51:29) 
>>> from optparse import OptionParser
>>> outputGroup = OptionGroup(parser, 'Output handling')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'OptionGroup' is not defined

This is strictly done with examples found on the docs, and you can't find anything about it anywhere, be it that long long docs page, google or stackoverflow. Plus, reading optparse.py shows OptionGroup is there, so that adds to the confusion.

I bet it will take less than 1 minute for someone to spot my error. For that I'll only add proper tags and / or modify the title later on. :)

© Stack Overflow or respective owner

Related posts about python

Related posts about optparse